home *** CD-ROM | disk | FTP | other *** search
- Path: oxy.rust.net!usenet
- From: pgunn@mail.cbf.com (Paul Gunn)
- Newsgroups: comp.lang.c++
- Subject: Re: Constructor Exceptions
- Date: Wed, 03 Jan 1996 13:28:11 GMT
- Organization: Rust Net - High Speed Internet in Detroit 810-642-2276
- Message-ID: <4ce0da$513@oxy.rust.net>
- References: <4bud9g$pv5@oxy.rust.net> <4cbhcl$kst@dawn.mmm.com>
- NNTP-Posting-Host: pgunn.cbf.com
- X-Newsreader: Forte Agent .99c/32.126
-
-
- >> Is this behavior parculiar to the Microsoft implementation or is it
- >> generally the case?
- >
- >It is not generally the case. Compilers that adhere to the standard
- >will produce code that does not leak memory in this way.
-
- Would you happen to know if Borland or any of the other PC compilers
- work properly in this area?
-
- >> I couldn't find any other reference to this issue in the ARM or other
- >> sources. In any event, it makes me very hesitant to throw exceptions
- >> from my constructors.
- >
- >I understand your hesitance. Exceptions are, IMHO, the best way to
- >report errors from constructors and overloaded operators. If your
- >compiler does not do it right, you may have to report the error in
- >some other way (such as an "ok()" function) or rework your constructor
- >so that it cannot fail (possibly by deferring some operations).
-
- I agree that using exceptions in constructors is the most elegant
- solution. Currently, I'm using a two phase initialization procedure
- where any questionable operations are performed in an Init() funtion.
- It works ok, but it would be nice if those functions could be
- performed in the constructor where they belong.
-
- I'll try to make a query to Microsoft to see if they plan on fixing
- this problem. Do you know of any portions of the draft standard or the
- ARM that address this issue? It would be nice if I could point out a
- specific breach in compliance.
-
- Thanks!
- Paul Gunn
-
-